var mine;
var creditLogType = [
    '绑定微信或者微博',
    '认证成为艺术家',
    '上链艺术品后台通过',
    '参拍出价',
    '拍下并交易完成',
    '关注十个用户',
    '关注五件艺术品',
    '关注五个艺术家',
    '对艺术品发表评论',
    '发表带图片的艺圈',
    '缴纳会费成为会员',
    '退出会员',
    '拍下商品后不付款',
    '系统活动',
    '在艺圈发表各种不良言论',
    '系统活动给予'
];
$(function () {
    mine = new Vue({
        el:'#mineController',
        data:{
            nav:_mineNav,
            userInfo:{},
            logs:[],
            logType:creditLogType,
            param:{
                recharge:false
            },
            recharge:{
                payType:1,
                money:288
            }
        },
        methods:{
            showRecharge:function (v) {
              this.param.recharge = v;
            },
            rechargeVip:function () {
                var that = this;
                sy.post('/web/pay/rechargeVip',{
                    payType:that.recharge.payType
                },function (data) {
                    if (data.errorCode){
                        sy.msg(data.errorMsg);
                        return;
                    }
                    if (that.recharge.payType == 1){
                        //支付宝
                        $("#content").val(data.pay);
                        $("#form").submit();
                    }else{
                        //微信二维码
                        var url = sy.path + '/qr?msg='+data.qr;
                        sy.showWxQrPay(data.price,url,function(){window.location.href = sy.path + "/web/home";},null);
                    }
                })
            },
            loadRechargeMoney:function(){
                var that = this;
              sy.postApi('/api/pay/vipMoeny',{},function (data) {
                  that.recharge.money = data;
              })
            },
            setReachargePayType:function (v) {
                this.recharge.payType = v;
            },
            loadData:function () {
                var that = this;
                sy.post('/web/home/findById',{},function (data) {
                    that.userInfo = data.data;
                    data = data.data;
                    if (data.userState == 1 && data.isVerify == 1){
                        that.userInfo.headImg = data.artImg;
                        that.userInfo.nickName = data.userName;
                    }
                })

                sy.post('/web/home/creditLog',{},function (data) {
                    if (data.code == 0){
                        that.logs = data.data;
                    }
                })
            },
            cancelVip:function () {
                var that = this;
                layer.confirm('您确定要取消超级会员？取消后将失去超级会员权限！', {
                    btn: ['确定','取消'] //按钮
                }, function(){
                    sy.postApi('/api/pay/applyRefund',{},function (data) {
                        layer.msg('取消成功', {icon: 1});
                        that.isVip = 0;
                    });
                }, function(){

                });
            }
        },
        created:function () {
            this.loadRechargeMoney();
            this.loadData();
        },
        mounted:function () {
            //显示/隐藏hash值
            $(document).on('click','.icon_scan',function(){
                if($(this).hasClass('scan_off')){
                    $(this).removeClass('scan_off');
                    $('.hash_code').hide();
                }else{
                    $(this).addClass('scan_off');
                    $('.hash_code').show();
                }
            });

        }
    });
})